#
# 
# Fichier Makefile projet intel Acceler8 sous license GNU GPL v3.
# Voir http://www.gnu.org/copyleft/gpl.html pour plus d'informations
# La license est egalement disponible dans le repertoire /doc.
# 
# Cree le : mardi 08 novembre 2011 à 18 : 10.
# Auteurs : Axel MOINET et Arnaud DURAND.
# 
# Nom de fichier : Makefile
# Chemin du fichier : ./src/
# 
# Description : Makefile du projet intel acceler8 version définitive.
# 
#

CC=icc
CXX=icpc
DEBUGGER=idb
INSPXE=inspxe-gui
VTUNE=amplxe-gui

CXX_FLAGS=-c -Wall
BUILD_DIR=.
SRC_DIR=.
LIBS=-ltbb -pthread
BIN_CXX_FLAGS= -Wall
BIN_DIR=.

TEST_OBJS=${BUILD_DIR}/subseqcompute.o ${BUILD_DIR}/cgh.o ${BUILD_DIR}/taskssumpmax.o ${BUILD_DIR}/taskpsumsmax.o ${BUILD_DIR}/pipelineresolution.o ${BUILD_DIR}/filtrecalculsoussequence.o ${BUILD_DIR}/filtreCalculCgh.o ${BUILD_DIR}/mainthreadfunctions.o ${BUILD_DIR}/threadprincipal.o ${BUILD_DIR}/parallelforcgh.o ${BUILD_DIR}/lecturefichier.o ${BUILD_DIR}/main.o ${BUILD_DIR}/readline.o ${BUILD_DIR}/filtrelectureligne.o ${BUILD_DIR}/filtreconverttoint.o ${BUILD_DIR}/prefixetabfunctions.o
TEST_NAME=test-lecture

OBJS=${BUILD_DIR}/taskssumpmax.o ${BUILD_DIR}/taskpsumsmax.o ${BUILD_DIR}/pipelineresolution.o ${BUILD_DIR}/filtrecalculsoussequence.o ${BUILD_DIR}/filtreCalculCgh.o ${BUILD_DIR}/mainthreadfunctions.o ${BUILD_DIR}/threadprincipal.o ${BUILD_DIR}/parallelforcgh.o ${BUILD_DIR}/lecturefichier.o ${BUILD_DIR}/main.o ${BUILD_DIR}/readline.o ${BUILD_DIR}/filtrelectureligne.o ${BUILD_DIR}/filtreconverttoint.o ${BUILD_DIR}/prefixetabfunctions.o

APP_NAME=run

#Premiere cible de compilation : all (utilise les fichiers fournis dans OBJS)
all : dependances ${APP_NAME}

${TEST_NAME} : ${TEST_OBJS}
	${CXX} ${BIN_CXX_FLAGS} $^ ${LIBS} -o ${BIN_DIR}/$@
	
dependances_test :
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/lecturefichier.o ${SRC_DIR}/classes/lecturefichier/lecturefichier.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/filtrelectureligne.o ${SRC_DIR}/classes/filtrelectureligne/filtrelectureligne.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/filtreconverttoint.o ${SRC_DIR}/classes/filtreconverttoint/filtreconverttoint.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/readline.o ${SRC_DIR}/classes/readline/readline.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/prefixetabfunctions.o ${SRC_DIR}/functions/prefixetabfunctions.cpp
	
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/parallelforcgh.o ${SRC_DIR}/classes/parallelforcgh/parallelforcgh.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/threadprincipal.o ${SRC_DIR}/classes/threadprincipal/threadprincipal.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/cgh.o ${SRC_DIR}/classes/cgh/cgh.cpp

	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/taskpsumsmax.o ${SRC_DIR}/classes/taskpsumsmax/taskpsumsmax.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/taskssumpmax.o ${SRC_DIR}/classes/taskssumpmax/taskssumpmax.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/subseqcompute.o ${SRC_DIR}/classes/subseqcompute/subseqcompute.cpp
	
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/filtreCalculCgh.o ${SRC_DIR}/classes/filtreCalculCgh/filtreCalculCgh.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/filtrecalculsoussequence.o ${SRC_DIR}/classes/filtrecalculsoussequence/filtrecalculsoussequence.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/pipelineresolution.o ${SRC_DIR}/classes/pipelineresolution/pipelineresolution.cpp
	
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/mainthreadfunctions.o ${SRC_DIR}/functions/mainthreadfunctions.cpp
	
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/main.o ${SRC_DIR}/main.cpp

#Cible pour la compilation de test de fonctions (utilise les fichiers fournis dans OBJS_TEST)
test : dependances_test ${TEST_NAME}

dependances :
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/lecturefichier.o ${SRC_DIR}/classes/lecturefichier/lecturefichier.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/filtrelectureligne.o ${SRC_DIR}/classes/filtrelectureligne/filtrelectureligne.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/filtreconverttoint.o ${SRC_DIR}/classes/filtreconverttoint/filtreconverttoint.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/readline.o ${SRC_DIR}/classes/readline/readline.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/prefixetabfunctions.o ${SRC_DIR}/functions/prefixetabfunctions.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/parallelforcgh.o ${SRC_DIR}/classes/parallelforcgh/parallelforcgh.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/threadprincipal.o ${SRC_DIR}/classes/threadprincipal/threadprincipal.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/taskpsumsmax.o ${SRC_DIR}/classes/taskpsumsmax/taskpsumsmax.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/taskssumpmax.o ${SRC_DIR}/classes/taskssumpmax/taskssumpmax.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/filtreCalculCgh.o ${SRC_DIR}/classes/filtreCalculCgh/filtreCalculCgh.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/filtrecalculsoussequence.o ${SRC_DIR}/classes/filtrecalculsoussequence/filtrecalculsoussequence.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/pipelineresolution.o ${SRC_DIR}/classes/pipelineresolution/pipelineresolution.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/mainthreadfunctions.o ${SRC_DIR}/functions/mainthreadfunctions.cpp
	${CXX} ${CXX_FLAGS} -o ${BUILD_DIR}/main.o ${SRC_DIR}/main.cpp

${APP_NAME} : ${OBJS}
	${CXX} ${BIN_CXX_FLAGS} $^ ${LIBS} -o ${BIN_DIR}/$@

#Lance le debuggage de l'application passee en parametre
debug :
	${DEBUGGER}

#Lance le mode inspxe de l'application passee en parametre
inspxe :
	${INSPXE}

#Lance le mode vtune de l'application passee en parametre
amplxe :
	${VTUNE}
	
clean :
	-rm ${BUILD_DIR}/*.o
	-rm ${BUILD_DIR}/run
